package org.example.codeservce.util;

import cn.novelweb.tool.http.Result;
import cn.novelweb.tool.upload.local.LocalUpload;
import cn.novelweb.tool.upload.local.pojo.UploadFileParam;
import lombok.SneakyThrows;
import org.apache.ibatis.annotations.Results;
import org.example.codeservce.comm.Q;

import javax.servlet.http.HttpServletRequest;

import static org.example.codeservce.config.FileConfig.FILEPATH_CONFIG;

/**
 * @author Li Qing
 * date: 2024/6/20 10:56
 * description:
 */
public class ToolCoreUtil
{
    @SneakyThrows
    public static Q getToolDescription(UploadFileParam param, HttpServletRequest request)
    {
        Result result = LocalUpload.fragmentFileUploader(param, FILEPATH_CONFIG, ZipUtilQ.ZIP_FILE_PATH, 5242880L, request);
        if ("201".equals(result.getCode()))
        {
            return Q.ok().q("fileInfo", result.getData());
        }
        return Q.no(Integer.parseInt(result.getCode()), result.getMessage());
    }
}
